package com.aiju.common.thread;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.Executor;

/**
 * @auther: 佐为
 * @date: 2016.8.15
 * @Description: 在主线程运行的线程池
 */

public class MainExecutor {

    public static Executor mainExecutor() {
        return new MainThreadExecutor();
    }

    static class MainThreadExecutor implements Executor {
        private final Handler handler = new Handler(Looper.getMainLooper());

        @Override
        public void execute(Runnable runnable) {
            handler.post(runnable);
        }
    }
}
